﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Web.UI;
using Newtonsoft.Json;

namespace MyWebApplication
{
    public partial class JqGridAjax : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //using (var db = new DBEntities())
            //{
            //List<TBProduct> productList = db.TBProduct.Where(p => p.IsDeleted != null)
            //    .OrderBy(p => p.ID)
            //    .Take(20)
            //    .OrderBy(p=>p.ID)
            //    .Take(10)
            //    .ToList();

            GridResultModel<DataTable> resultModel = new GridResultModel<DataTable>();
            SearchModel searchModel = PagerUtil.GetConditions();
            string sql = "select ID,ProductName,ProductCode,CostPrice,VipPrice,ImageUrl from TBProduct where isdeleted=0 ";
            PagerUtil.CurrentPageData(sql, searchModel, resultModel);
            
            string jsonResult = JsonConvert.SerializeObject(resultModel);
            Response.ContentType = "text/html";
            Response.ContentEncoding = Encoding.UTF8;
            Response.Write(jsonResult);
            Response.End();
            //}
        }
    }
}